layui.config({
    base: "/layui/"
}).extend({
    index: 'lib/index'
}).use(['index', 'form', 'jquery', 'table', 'laydate'], function () {
    var form = layui.form,
        table = layui.table,
        admin = layui.admin,
        laydate = layui.laydate;

    //执行一个laydate实例
    laydate.render({
        elem: '#start_time' //指定元素
    });
    laydate.render({
        elem: '#end_time' //指定元素
    });

    table.render({
        elem: '#chart_table'
        , url: '/dayCount/queryList'
        , method: "post"
        , height: 500
        , limit: 20							//显示数目
        , limits: [20, 100]
        , cols: [[
            {field: 'userId', title: '商家id', width: 100, "align": "center"}
            ,{field: 'userName', title: '商家名称', width: 120, "align": "center"}
            , {field: 'sn', width: 220, title: '设备编号', "align": "center"}
            , {field: 'wCount', width: 250, title: '微信笔数', "align": "center",templet:function (d) {
                    return d.wcount+"/20";
                }}
            , {field: 'aCount', width: 250, title: '支付宝笔数', "align": "center",templet:function (d) {
                    return d.acount+"/20";
                }}
            , {field: 'payDay', width: 200, title: '日期', "align": "center"}
        ]]
        , request: {
            pageName: 'pageNo' //页码的参数名称，默认：page
            , limitName: 'pageSize' //每页数据量的参数名，默认：limit
        },
        where: {
            startTime: $(".queryTable input[name='startTime']").val(),
            endTime: $(".queryTable input[name='endTime']").val(),
            mchUserName: $(".queryTable input[name='mchUserName']").val()
        }
        , id: 'chart_table'
        , page: true
    });

    $(".search_btn").click(function () {
        table.reload('chart_table', {
            page: {
                curr: 1 //重新从第 1 页开始
            }
            ,where: {
                startTime: $(".queryTable input[name='startTime']").val(),
                mchUserName: $(".queryTable input[name='mchUserName']").val(),
                endTime: $(".queryTable input[name='endTime']").val()
            }
        });
    });

});

